package com.cctv.video.presenter;



import com.cctv.video.api.ApiRetrofit;
import com.cctv.video.api.BasePresenter;
import com.cctv.video.api.HomeCApiServer;
import com.cctv.video.network.mvp.BaseModel;
import com.cctv.video.network.mvp.BaseObserver;
import com.cctv.video.presenter.IView.HomeCView;

import java.util.HashMap;

/**
 * 作者：created by LP_TREAM on 2020/11/28 23:27
 * 邮箱：806875201@qq.com
 */

public class HomeCPresenter extends BasePresenter<HomeCView> {
    public HomeCPresenter(HomeCView baseView) {
        super(baseView);
    }

    /**
     * 普通接口请求
     */
    public void getText() {
        HashMap<String, String> params = new HashMap<>();
        params.put("type", "junshi");
        params.put("key", "2c1cb93f8c7430a754bc3ad62e0fac06");
        addDisposable(ApiRetrofit.getInstance(HomeCApiServer.class).getText(params), new BaseObserver(baseView) {
            @Override
            public void onSuccess(BaseModel o) {
                baseView.onTextSuccess(o);
            }
        });
    }

    /**
     * 获取随机笑话
     *
     * @param baseUrl
     */
    public void getJokeList(String baseUrl) {
        HashMap<String, String> params = new HashMap<>();
        params.put("num", "10");
        addDisposable(ApiRetrofit.getBaseUrlInstance(HomeCApiServer.class, baseUrl).getJokeList(params), new BaseObserver(baseView) {
            @Override
            public void onSuccess(BaseModel o) {
                baseView.onJokeListSuccess(o);
            }
        });
    }


}
